/**
 * 
 */
package org.totalbeginner.tutorial;

/**
 * @author Ibraheem.Abdullah
 *
 */
public class Book {

	String title;
	String author;
	Person person;

	public Book(String title) {
		this.setTitle(title);
		this.setAuthor("Unknown Author");
	}

	public Book(String title, String author) {
		this.setTitle(title);
		this.setAuthor(author);
	}

	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * @param title the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}

	/**
	 * @return the author
	 */
	public String getAuthor() {
		return author;
	}

	/**
	 * @param author the author to set
	 */
	public void setAuthor(String author) {
		this.author = author;
	}

	public void setPerson(Person p1) {
		this.person = p1;
	}
	
	public Person getPerson() {
		return this.person;
	}
	
	public String toString(){
		String available = " is available";
		String toReturn = this.getTitle() + " by " + this.getAuthor();
		if(this.getPerson() != null){
			available = " is checked out by " + this.getPerson().getName();
		}
		toReturn+= available;
		return toReturn;
	}

}
